	// ResultMessage.java
// Provides a message-formatted XML response

package messages;

import java.util.ArrayList;

public class ResultMessage extends Message
{
	private int value = 0; // return value
	private ArrayList<String> details = new ArrayList<String>(); // <details> <first>, <second>, <third>, etc. </details>
	
	public ResultMessage() {super("Result");}
	
	public ResultMessage(int value, ArrayList<String> details)
	{
		super("Result");
		this.value = value;
		this.details = details;
	}
	
	public void addToDetails(String detail)
	{
		details.add(detail);
	}
	
	public int getValue() {return value;}
	public ArrayList<String> getDetails() {return details;}
	public String getDetail(int index) {return details.get(index);}
	
	public void setValue(int value) {this.value = value;}
	public void setDetails(ArrayList<String> details) {this.details = details;}
	
	// return an XML-formatted version of the message
	public String toXML()
	{
		String message = "<message>";
        message += "<type>Result</type>";
        message += "<value>" + value + "</value>";
        message += "<details>";
        
        for(String detail : details)
        {
        	message += "<detail>" + detail + "</detail>";
        }
        
        message += "</details>";
        message += "</message>\n\0";
        
        return message;
	}
}
